package Thread;

import java.util.concurrent.Semaphore;

/**
 * @Title: Demo6
 * @Author 郑雨杭
 * @Package Thread
 * @Date 2024/7/7 13:25
 * @description:
 */
public class Demo6 {
    public static void main(String[] args) throws InterruptedException {
        Semaphore semaphore = new Semaphore(4);
        semaphore.acquire();
        System.out.println("p 操作");
        semaphore.acquire();
        System.out.println("p 操作");
        semaphore.acquire();
        System.out.println("p 操作");
        semaphore.acquire();
        System.out.println("p 操作");
        semaphore.release();
        System.out.println("v 操作");
        semaphore.acquire();
        System.out.println("p 操作");
        semaphore.acquire();
        System.out.println("p 操作");
    }
}
